
import {delStatus} from './gameStatusListServ.js'
import { isEmpty, isArray, cloneDeep, merge } from 'lodash'
import { message } from 'antd';

const defultState = {
    biz:{

    },
}

// 声明module
const tmpModule = {
    namespace: 'gameStatusListModel',
    state: cloneDeep(defultState),
    subscriptions: {
        setup({ dispatch, history }) {
            history.listen(({ pathname, query }) => {
                if ('' + tmpModule.pathname === '' + pathname) {
                    //   dispatch({type: 'queryInfo', payload: {}}) // end dispatch
                    dispatch({ type: 'updateStore', payload: cloneDeep(defultState) });
                }
            })
        },
    },


    // 方法列表
    effects: {
        *delGameStatus({ payload }, { put, call, select }) {
			try {
                const { success,result } = yield call(delStatus, { ...payload });
                if (success) {
                    let defultState = yield select(state => state[tmpModule.namespace])
                    defultState.biz.refreshListDatas(true)
                    message.success('删除游戏类型成功');
                }
			} catch (e) {
				console.log(e)
			}

        },
    },

    // reducers: {
    //   updateStore(preState, action) {
    //     return Object.assign({}, preState, action.payload)
    //   },
    // }
    reducers: {
        updateStore(preState, action) {
            return { ...preState, ...action.payload };
        }
    }
}

export default tmpModule
